32 research outputs found

    Formal Compiler Implementation in a Logical Framework

    Get PDF
    The task of designing and implementing a compiler can be a difficult and error-prone process. In this paper, we present a new approach based on the use of higher-order abstract syntax and term rewriting in a logical framework. All program transformations, from parsing to code generation, are cleanly isolated and specified as term rewrites. This has several advantages. The correctness of the compiler depends solely on a small set of rewrite rules that are written in the language of formal mathematics. In addition, the logical framework guarantees the preservation of scoping, and it automates many frequently-occurring tasks including substitution and rewriting strategies. As we show, compiler development in a logical framework can be easier than in a general-purpose language like ML, in part because of automation, and also because the framework provides extensive support for examination, validation, and debugging of the compiler transformations. The paper is organized around a case study, using the MetaPRL logical framework to compile an ML-like language to Intel x86 assembly. We also present a scoped formalization of x86 assembly in which all registers are immutable

    A Computational Approach to Reflective Meta-Reasoning about Languages with Bindings

    Get PDF
    We present a foundation for a computational meta-theory of languages with bindings implemented in a computer-aided formal reasoning environment. Our theory provides the ability to reason abstractly about operators, languages, open-ended languages, classes of languages, etc. The theory is based on the ideas of higher-order abstract syntax, with an appropriate induction principle parameterized over the language (i.e. a set of operators) being used. In our approach, both the bound and free variables are treated uniformly and this uniform treatment extends naturally to variable-length bindings. The implementation is reflective, namely there is a natural mapping between the meta-language of the theorem-prover and the object language of our theory. The object language substitution operation is mapped to the meta-language substitution and does not need to be defined recursively. Our approach does not require designing a custom type theory; in this paper we describe the implementation of this foundational theory within a general-purpose type theory. This work is fully implemented in the MetaPRL theorem prover, using the pre-existing NuPRL-like Martin-Lof-style computational type theory. Based on this implementation, we lay out an outline for a framework for programming language experimentation and exploration as well as a general reflective reasoning framework. This paper also includes a short survey of the existing approaches to syntactic reflection

    Practical Reflection for Sequent Logics

    Get PDF
    AbstractIt is well-known that adding reflective reasoning can tremendously increase the power of a proof assistant. In order for this theoretical increase of power to become accessible to users in practice, the proof assistant needs to provide a great deal of infrastructure to support reflective reasoning. In this paper we explore the problem of creating a practical implementation of such a support layer.Our implementation takes a specification of a logical theory (which is identical to how it would be specified if we were simply going to reason within this logical theory, instead of reflecting it) and automatically generates the necessary definitions, lemmas, and proofs that are needed to enable the reflected meta-reasoning in the provided theory.One of the key features of our approach is that the structure of a logic is preserved when it is reflected. In particular, all variables, including meta-variables, are preserved in the reflected representation. This also allows the preservation of proof automationā€”there is a structure-preserving one-to-one map from proof steps in the original logic to proof step in the reflected logic.To enable reasoning about terms with sequent context variables, we develop a principle for context induction, called teleportation.This work is fully implemented in the MetaPRL theorem prover

    Abstract Writing Constructive Proofs Yielding Efficient Extracted Programs

    No full text
    The NuPRL system [3] was designed for interactive writing of machineā€“checked constructive proofs and for extracting algorithms from the proofs. The extracted algorithms are guaranteed to be correct 1 which makes it possible to use NuPRL as a programming language with built-in verification[1,5,7,8,9,10]. However it turned out that proofs written without algorithmic efficiency in mind often produce very inefficient algorithms ā€” exponential and double-exponential ones for problems that can be solved in polynomial time. In this paper we present some general principles of efficient programming in constructive type theory as well as describe a case study that shows how these principles apply to particular problems. We consider the proof of the Myhillā€“Nerode automata minimization theorem from the NuPRL automata library [4] which leaded to a doubleā€“exponential (in time) extracted program. Systematic use of the presented principles allowed us to build a new complexity cautious proof leading to polynomial-time algorithm extracted by the same NuPRL extractor. We believe that the principles presented in this paper in combination with other methods may lead to an efficient technique of programming-by-proofs. Key Words and Phrases: automata, constructivity, Myhill-Nerode theorem, NuPRL, program extraction, program verification, programming by extracts, state minimization.

    Improving the Efficiency of Nuprl Proofs

    No full text
    In order to use Nuprl system as a programming language with builtin verification one has to improve the efficiency of the programs extracted from the Nuprl proofs. In the current paper we consider proofs from the Nuprl automata library. In some of these proofs (pigeon-hole principle, decidability of the state reachability, decidability of the equivalence relation on words induced by the automata language) sources of exponential-time complexity have been detected and replaced by new complexity cautious proofs. The new proofs now lead to polynomial-time algorithms extracted by the same Nuprl extractor, thus eliminating all known unnecessary exponentials from the Nuprl automata library. General principles of efficient programming on Nuprl are also discussed. Key Words and Phrases: automata, constructivity, Myhill-Nerode theorem, Nuprl, program extraction, program verification, state minimization

    Formalizing type operations using the ā€œImageā€ type constructor

    Get PDF
    In this paper we introduce a new approach to formalizing certain type operations in type theory. Traditionally, many type constructors in type theory are independently axiomatized and the correctness of these axioms is argued semantically. In this paper we introduce a notion of an ā€œimage ā€ of a given type under a mapping that captures the spirit of many of such semantical arguments. This allows us to use the new ā€œimage ā€ type to formalize within the type theory a large range of type constructors that were traditionally formalized via postulated axioms. We demonstrate the ability of the ā€œimage ā€ constructor to express ā€œforgetful ā€ types by using it to formalize the ā€œsquash ā€ and ā€œset ā€ type constructors. We also demonstrate its ability to handle types with non-trivial equality relations by using it to formalize the union type operator. We demonstrate the ability of the ā€œimage ā€ constructor to express certain inductive types by showing how the type of lists and a higher-order abstract syntax type can be naturally formalized using the new type constructor. The work presented in this paper have been implemented in the MetaPRL proof assistant and all the derivations checked by MetaPRL

    Markov's Principle for Propositional Type Theory

    No full text
    In this paper we show how to extend a constructive type theory with a principle that captures the spirit of Markov's principle from constructive recursive mathematics. Markov's principle is especially useful for proving termination of specific computations. Allowing a limited form of classical reasoning we get more powerful resulting system which remains constructive and valid in the standard constructive semantics of a type theory. We also show that this principle can be formulated and used in a propositional fragment of a type theory

    c ā—‹ 2005 Kluwer Academic Publishers. Printed in the Netherlands. 1 Formal Compiler Construction in a Logical Framework

    No full text
    Abstract. The task of designing and implementing a compiler can be a difficult and error-prone process. In this paper, we present a new approach based on the use of higher-order abstract syntax and term rewriting in a logical framework. All program transformations, from parsing to code generation, are cleanly isolated and specified as term rewrites. This has several advantages. The correctness of the compiler depends solely on a small set of rewrite rules that are written in the language of formal mathematics. In addition, the logical framework guarantees the preservation of scoping, and it automates many frequently-occurring tasks including substitution and rewriting strategies. As we show, compiler development in a logical framework can be easier than in a general-purpose language like ML, in part because of automation, and also because the framework provides extensive support for examination, validation, and debugging of the compiler transformations. The paper is organized around a case study, using the MetaPRL logical framework to compile an ML-like language to Intel x86 assembly. We also present a scoped formalization of x86 assembly in which all registers are immutable

    Extensible hierarchical tactic construction in a logical framework. Accepted to the TPHOLs 2004 conference

    No full text
    Abstract. Theorem provers for higher-order logics often use tactics to implement automated proof search. Often some basic tactics are designed to behave very differently in different contexts. Even in a prover that only supports a fixed base logic, such tactics may need to be updated dynamically as new definitions and theorems are added. In a logical framework with multiple (perhaps conflicting) logics, this has the added complexity that definitions and theorems should only be used for automation only in the logic in which they are defined or proved. This paper describes a very general and flexible mechanism for extensible hierarchical tactic maintenance in a logical framework. We also explain how this reflective mechanism can be implemented efficiently while requiring little effort from its users. The approaches presented in this paper form the core of the tactic construction methodology in the MetaPRL theorem prover, where they have been developed and successfully used for several years.
    corecore